package com.GainLoop.Api.Entity;

import com.GainLoop.Api.ApiException;
import com.GainLoop.Api.ApiResponseArray;
import com.google.gson.annotations.SerializedName;

public class Gain extends EntityAbstract {
	
	public enum STATUS {
		ACTIVE,
		CANCELED,
		SATISFIED,
		SUSPENDED
	}

	@SerializedName("id")
	private long _id;

	@SerializedName("toUserId")
	private long _toUserId;

	@SerializedName("fromUserId")
	private long _fromUserId;

	@SerializedName("categoryId")
	private long _categoryId;
		
	@SerializedName("description")
	private String _description;
		
	@SerializedName("status")
	private int _status;

	@SerializedName("linksNum")
	private long _linksNum;

	@SerializedName("tagsNum")
	private long _tagsNum;
	
	

	public long getId()
	{
		return this._id;
	}
	
	public void setId(long id)
	{
		if(id < 0) {
			throw new ApiException("id must be unsigned");
		}
		this._id = id;
	}
	
	public long getToUserId()
	{
		return this._toUserId;
	}
	
	public void setToUserId(long toUserId)
	{
		if(toUserId < 0) {
			throw new ApiException("toUserId must be unsigned");
		}
		this._toUserId = toUserId;
	}
	
	public long getFromUserId()
	{
		return this._fromUserId;
	}
	
	public void setFromUserId(long fromUserId)
	{
		if(fromUserId < 0) {
			throw new ApiException("fromUserId must be unsigned");
		}
		this._fromUserId = fromUserId;
	}
	
	public long getCategoryId()
	{
		return this._categoryId;
	}
	
	public void setCategoryId(long categoryId)
	{
		if(categoryId < 0) {
			throw new ApiException("categoryId must be unsigned");
		}
		this._categoryId = categoryId;
	}
	
	public String getDescription()
	{
		return this._description;
	}
	
	public void setDescription(String description)
	{
		this._description = description;
	}
	
	public STATUS getStatus()
	{
		switch(this._status) {
		case 0:
			return STATUS.ACTIVE;
		case -1:
			return STATUS.CANCELED;
		case 10:
			return STATUS.SATISFIED;
		case 5:
			return STATUS.SUSPENDED;
			
		default:
			throw new ApiException("The status " + this._status + " is unknown");
		}
	}
	
	public void setStatus(STATUS status)
	{
		if(status == STATUS.ACTIVE)
			this._status = 0;
		else if(status == STATUS.CANCELED)
			this._status = -1;
		else if(status == STATUS.SATISFIED)
			this._status = 10;
		else if(status == STATUS.SUSPENDED)
			this._status = 5;
		else 
			throw new ApiException("The status " + status + " is unknown");
	}
	
	public long getLinksNum()
	{
		return this._linksNum;
	}
	
	public long getTagsNum()
	{
		return this._tagsNum;
	}
	
	public String toString()
	{
		return "Gain[" + this._id + "]";
	}
	
	public static String statusToString(STATUS status){
		
		if(status == STATUS.ACTIVE)
			return "ACTIVE";
		else if(status == STATUS.CANCELED)
			return "CANCELED";
		else if(status == STATUS.SATISFIED)
			return "SATISFIED";
		else if(status == STATUS.SUSPENDED)
			return "SUSPENDED";
		else 
			throw new ApiException("The status " + status + " is unknown");
	}
}
